package com.wing.user.model.request;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 系统用户
 *
 * @author
 */
@Data
public class User extends BaseEntity<User> {

    public enum IsJob implements IEnum<Integer> {

        /**
         * 在职
         */
        job(0,"在职"),
        /**
         * 离职
         */
        resign(1,"离职"),
        /**
         * 退休
         */
        retire(2,"退休");

        private int code;
        private String desc;

        IsJob(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
        @JsonCreator
        public static IsJob jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (IsJob item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    /**
     * 用户名（工号）
     */
    private String username;

    /**
     * 昵称（姓名）
     */
    private String nickname;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 旧手机号
     */
    private String oldPhone;

    /**
     * 密码
     */
    private String password;

    /**
     * RSA加密密码
     */
    private String passwordRsa;

    /**
     * 启用禁用，0-禁用，1-启用。
     */
    private Integer status;

    /**
     * 性别，0-女，1-男。
     */
    private Integer sex;

    /**
     * 住址
     */
    private String address;

    /**
     * 头像地址
     */
    private String headerImg;

    /**
     * 第三方联合登录授权后返回的openId
     */
    private String openId;

    /**
     * 邮箱
     */
    private String email;

    /*新增字段*/
    /**
     * 企业ID
     */
    private Long companyInfoId;

    /**
     * 部门ID
     */
    private Long departmentId;

    /**
     * 岗位ID
     */
    private Long postId;

    /**
     * 职务ID
     */
    private Long positionId;

    /**
     * 身份证号
     */
    private String idCard;

    /**
     * 身份证正面照
     */
    private String frontPhoto;

    /**
     * 身份证背面照
     */
    private String backPhoto;

    /**
     * 入职时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate entryTime;

    /**
     * 工资卡开户行
     */
    private String bank;

    /**
     * 工资卡账号
     */
    private String account;

    /**
     * 银行卡照片
     */
    private String bankCardPhoto;

    /**
     * 生日
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;

    /**
     * 是否在职:job(0,在职);resign(1,离职);retire(2,退休)
     */
    private IsJob isJob;

    /**
     * 社保基数
     */
    private Integer socialSecurityBase;

    /**
     * 社保始缴月
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate startMonthSocialSecurity;

    /**
     * 公积金基数
     */
    private Integer providentFundBase;

    /**
     * 公积金始缴月
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate startMonthProvidentFund;

    /**
     * 排序
     */
    private Integer sortNumber;
    /*新增字段*/

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username=" + username +
                ", password=" + password +
                ", status=" + status +
                ", nickname=" + nickname +
                ", sex=" + sex +
                ", address=" + address +
                ", headerImg=" + headerImg +
                ", openId=" + openId +
                ", createTime=" + createTime +
                "}";
    }


    /**
     * 角色
     */
    @TableField(exist = false)
    private List<Role> roles;

    @TableField(exist = false)
    private String enterpriseId;

    /**
     * 是否拥有柜子面板的设置权限
     */
    private Boolean hasSettingRole;

    private Boolean hasWcabSettingRole;

    /**
     * 企业编码
     */
    private String enterpriseCode;

    /**
     * 公司名称
     */
    @TableField(exist = false)
    private String companyInfoName;

    /**
     * 部门名称
     */
    @TableField(exist = false)
    private String departmentName;

    /**
     * 用户角色编码
     */
    private String userRoleCode;

    /**
     * 主柜选择
     */
    private String cabinet;


    private String faceData;

    private String icCard;

    @TableField(exist = false)
    private String companyName;

    @TableField(exist = false)
    private String newPwd;

    @TableField(exist = false)
    private String oldPwd;

    private Boolean isUpdatePwd;
    @TableField(exist = false)
    private String cabAuthCodes;
    @TableField(exist = false)
    private String wcabAuthCodes;

    private Long thirdPartyDepartmentId;

    private Long thirdPartyUserId;
    @TableField(exist = false)
    private String roleIds;

    private Long thirdPartyJobtitleId;


    /**
     * 钉钉用户id
     */
    private String dingUserId;

    /**
     * 钉钉用户所属的部门id
     */
    private Long dingDepartmentId;
}
